<template>
  <div class="body1" style="padding-top:10px;">
    <div class="form_select">
      <div>
          <el-input class="select_input1" v-model="form.orderNum" 
          size="small" placeholder="单号"></el-input>
          <el-date-picker
            @change="dateChage"
            v-model="form.date"
            type="date"
            placeholder="盘点日期" 
            size="small" 
            class="select_option1"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            >
          </el-date-picker>
          <el-button type="primary"  size="small" @click="getList">&nbsp;搜&nbsp;&nbsp;索&nbsp;</el-button>
      </div>
      <div class="select_right">
          <el-button type="primary"  size="small" @click="exportExcel">导出Excel</el-button>
          <!--<el-button type="primary"  size="small">新增客户</el-button>-->
      </div>
    </div>
    <checkTable :list="list" @func="editTrue"></checkTable>
    <checkItem :list="itemList" @func="editTrue" :show="itemShow"></checkItem>
  </div>
</template>

<script>
import checkTable from "./checkTable"
import checkItem from "./checkItem"
import {excelExport} from "../../public/excelExport"
  export default {
    data() {
      return {
        list:[],
        form:{},
        itemShow:false,
        itemList:[]
      };
    },
    components: {
      "checkTable": checkTable,
      "checkItem":checkItem
    },
    created: function() {
      this.getList()
    },
    methods: {
      getList:function(){
        this.form.store_id = localStorage.getItem('store_id')
        var that = this
        this.$get('form/check',this.form).then((res) => {
          that.list = res.data
        })
      },
      dateChage:function(e){
        this.form.date = e
      },
      exportExcel:function() {
        let title = '盘点表'
        excelExport(title)
        return false;
      },
      editTrue:function(data){
        this[data.key] = !this[data.key]
        if(data.id){
          var that = this
          this.$get('form/checkItem',{id:data.id}).then((res) => {
            that.itemList =  res.data
          })
        }
      }
  }
};
</script>
<style>



</style>